package com.user.controller;

import com.user.api.UserApi;
import com.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserApi userApi;

    /**
     * 列表
     * @param user
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list")
    public Object getList(@RequestBody User user, @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "3") Integer pageSize){
        return userApi.getList(user,pageNum,pageSize);
    }

    /**
     * 登录
     * @param user
     * @return
     */
    @RequestMapping("login")
    public Object login(@RequestBody User user){
        return userApi.login(user);
    }

    /**
     * 注册
     * @param user
     * @return
     */
    @RequestMapping("save")
    public Object save(@RequestBody User user){
        return userApi.save(user);
    }
}
